package com.diploma.interaction.service.impl;

import com.diploma.interaction.mapper.DjnsrxxTestMapper;
import com.diploma.interaction.model.DjnsrxxTest;
import com.diploma.interaction.model.DjnsrxxTestExample;
import com.diploma.interaction.service.DjNsrxxService;

import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@Service
@Slf4j
public class DjNsrxxServiceImpl implements DjNsrxxService {

    @Resource
    DjnsrxxTestMapper djNsrxxMapper;

    @Override
    public int deleteById(int id) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andDjxhEqualTo(BigDecimal.valueOf(id));
        return djNsrxxMapper.deleteByExample(djNsrxxExample);
    }


    @Override
    public void insertSelective(DjnsrxxTest record) {
         djNsrxxMapper.insert(record);
    }

    @Override
    public List<DjnsrxxTest> selectById(int id) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andDjxhEqualTo(BigDecimal.valueOf(id));
        return djNsrxxMapper.selectByExample(djNsrxxExample);
    }

    @Override
    public int updateByIdSelective(DjnsrxxTest record, int id) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andDjxhEqualTo(BigDecimal.valueOf(id));
        return djNsrxxMapper.updateByExampleSelective(record,djNsrxxExample);
    }

    @Override
    public DjnsrxxTest selectByPrimaryKey(int id) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andDjxhEqualTo(BigDecimal.valueOf(id));
        return  djNsrxxMapper.selectByExample(djNsrxxExample).get(0);


    }

    @Override
    public List<DjnsrxxTest> selectByZjlxAndZjhm(String zjlx, String zjhm) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andFddbrsfzjlxDmEqualTo(zjlx).andFddbrsfzjhmEqualTo(zjhm);
        return  djNsrxxMapper.selectByExample(djNsrxxExample);
    }

    @Override
    public DjnsrxxTest selectByDjxh(BigDecimal djxh) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andDjxhEqualTo(djxh);
        return  djNsrxxMapper.selectByExample(djNsrxxExample).get(0);
    }

    @Override
    public DjnsrxxTest selectByNsrsbh(String nsrsbh) {
        DjnsrxxTestExample djNsrxxExample=new DjnsrxxTestExample();
        djNsrxxExample.createCriteria().andNsrsbhEqualTo(nsrsbh);
        return  djNsrxxMapper.selectByExample(djNsrxxExample).get(0);
    }
}
